import request from '../../utils/request';

// 会员管理相关 API

// 更新会员用户类型
export const updateUserType = (id: string, userType: number) => {
    return request({
        url: `/member/api/${id}/user-type`,
        method: 'put',
        params: { userType }
    });
};

// 修改会员
export const updateMember = (data: any) => {
    return request({
        url: '/member/api/update',
        method: 'put',
        data
    });
};

// 修改会员手机号
export const updatePhone = (data: any) => {
    return request({
        url: '/member/api/phone',
        method: 'put',
        data
    });
};

// 修改会员密码
export const updatePassword = (data: any) => {
    return request({
        url: '/member/api/password',
        method: 'put',
        data
    });
};

// 发送手机验证码
export const sendMemberVerificationCode = (phone: string, type: string) => {
    return request({
        url: '/member/api/send-verification-code',
        method: 'post',
        params: { phone, type }
    });
};

// 会员注册
export const registerMember = (data: any) => {
    return request({
        url: '/member/api/register',
        method: 'post',
        data
    });
};

// 批量查询会员信息
export const getMembersByIds = (memberIds: string) => {
    return request({
        url: '/member/api/batch',
        method: 'get',
        params: { memberIds }
    });
};

// 批量查询会员详情
export const getMembersByIdList = (data: any) => {
    return request({
        url: '/member/api/batch',
        method: 'post',
        data
    });
};

// 根据ID查询会员
export const getMemberById = (id: string) => {
    return request({
        url: `/member/api/${id}`,
        method: 'get'
    });
};

// 删除会员
export const deleteMember = (id: string) => {
    return request({
        url: `/member/api/${id}`,
        method: 'delete'
    });
};

// 根据微信openId查询会员
export const getMemberByWechatOpenId = (openId: string) => {
    return request({
        url: `/member/api/wechat/${openId}`,
        method: 'get'
    });
};

// 根据手机号查询会员
export const getMemberByPhone = (phone: string) => {
    return request({
        url: `/member/api/phone/${phone}`,
        method: 'get'
    });
};

// 分页查询会员列表
export const getMemberPage = (params: any) => {
    return request({
        url: '/member/api/page',
        method: 'get',
        params
    });
};

// 查询会员列表
export const getMemberList = (params: any) => {
    return request({
        url: '/member/api/list',
        method: 'get',
        params
    });
};

// 获取启用的会员
export const getEnabledMembers = () => {
    return request({
        url: '/member/api/enabled',
        method: 'get'
    });
};
